package cn.wolfcode.service.impl;

import cn.wolfcode.mapper.AccountMapper;
import cn.wolfcode.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
@Service
@Transactional
public class AccountServiceImpl implements IAccountService {
    private AccountMapper accountMapper;
    @Autowired
    public void setAccountMapper(AccountMapper accountMapper) {
        this.accountMapper = accountMapper;
    }

    @Override
    public void tranfer(Long outId, Long inId, BigDecimal amount) {
        accountMapper.subtractBalance(outId,amount);
       // System.out.println(1/0);
        accountMapper.AddBalance(inId,amount);

    }
}
